package StudyCode.summary.zipfile;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ExtractFileFromZipFileUsingCommandLineArguments {
	public static void main(String args[]) {
		String strZipFile = "E:/Copy/zipdemo.zip";
		String strDestinationPath = "";

		try {
			FileInputStream fin = new FileInputStream(strZipFile);
			ZipInputStream zin = new ZipInputStream(fin);
			ZipEntry entry = zin.getNextEntry();
			OutputStream os = new FileOutputStream(strDestinationPath + "/" + entry.getName());
			byte[] buffer = new byte[1024];
			int length;
			while ((length = zin.read(buffer)) > 0) {
				os.write(buffer, 0, length);
			}
			os.close();
			zin.close();
			System.out.println("zip文件已解压文件");
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
